package com.evil.kingdom.pojo.entity.world.city;

import com.evil.kingdom.pojo.entity.action.Position;
import com.evil.kingdom.pojo.entity.base.Belong;
import com.evil.common.mongo.entity.SingleName;
import com.evil.kingdom.pojo.entity.person.base.Person;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.Objects;

/**
 * 城池
 *
 * @author liyang
 * @date 2024-05-17 17:38
 */
@Getter
@Setter
@Document
public class City implements Position, Belong, SingleName {

    /**
     * 名称
     */
    @Id
    @NotBlank(message = "名称不能为空")
    private String name;

    /**
     * 归属（君主）
     *
     * @see Person#getName()
     */
    private String belong;

    /**
     * 主帅/太守
     *
     * @see Person#getName()
     */
    private String marshalName;

    /**
     * X坐标
     */
    @NotNull(message = "x坐标不能为空")
    private Double x;

    /**
     * y
     */
    @NotNull(message = "y坐标不能为空")
    private Double y;

    @Override
    public String getEntityName() {
        return "城池";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        City city = (City) o;

        return Objects.equals(name, city.name);
    }

    @Override
    public int hashCode() {
        return name != null ? name.hashCode() : 0;
    }
}
